import http from '@/utils/http'

const BASE_URL = '/asset/producer/records'

export interface ProducerRecordsResp {
  code:string
  name: string
  producerName: string
  description: string
  address: string
  contacts: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
  disabled: boolean
}
export interface ProducerRecordsDetailResp {
  id: string
  code:string
  name: string
  producerName: string
  description: string
  address: string
  contacts: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface ProducerRecordsQuery {
  name: string | undefined
  sort: Array<string>
}
export interface ProducerRecordsPageQuery extends ProducerRecordsQuery, PageQuery {}

/** @desc 查询厂商列表 */
export function listProducerRecords(query: ProducerRecordsPageQuery) {
  return http.get<PageRes<ProducerRecordsResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询厂商详情 */
export function getProducerRecords(id: string) {
  return http.get<ProducerRecordsDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增厂商 */
export function addProducerRecords(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改厂商 */
export function updateProducerRecords(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除厂商 */
export function deleteProducerRecords(id: string) {
  return http.del(BASE_URL, { ids: [id] })
}

/** @desc 导出厂商 */
export function exportProducerRecords(query: ProducerRecordsQuery) {
  return http.download(`${BASE_URL}/export`, query)
}
